package practice03;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice01
 * @ClassName: CalAbsolute
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/3 10:26
 * @Copyright 大牛版板所有
 */
public class CalAbsolute {

    public int absolute(int n){
        int num;
        if (n < 0){
            num = -n;
        }
        else {
            num = n;
        }
        return num;
    }

    public double absolute(double n){
        double num;
        if (n < 0){
            num = -n;
        }
        else {
            num = n;
        }
        return num;
    }

    public float absolute(float n){
        float num;
        if (n < 0){
            num = -n;
        }
        else {
            num = n;
        }
        return num;
    }

    public static void main(String[] args) {
        CalAbsolute absolute = new CalAbsolute();
        int num1 = absolute.absolute(0);
        System.out.println("int型求绝对值："+num1);

        double num2 = absolute.absolute(3.3);
        System.out.println("double型求绝对值："+num2);

        float num3 = absolute.absolute(2f);
        System.out.println("float型求绝对值："+num3);
    }
}
